fix(v2): propagate Retina backing scale factor to WKWebView#5212
fix(v2): propagate Retina backing scale factor to WKWebView#5212leaanthony wants to merge 1 commit into
Conversation
WKWebView does not automatically propagate the display's backing scale factor to JavaScript's devicePixelRatio when content is loaded via a custom URL scheme (wails://). This causes devicePixelRatio to return 1 on Retina displays, resulting in blurry canvas rendering. Fix by calling _setOverrideDeviceScaleFactor: on the WKWebView after initialization with the screen's backingScaleFactor. This SPI is stable since macOS 10.11 and is used by Electron, Playwright, and WebKit's own test infrastructure. Fixes #5111
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
🤖 PR Triage Review ✅ Accepted Propagates Retina backing scale factor to WKWebView (v2 macOS). Fixes high-DPI rendering. Platform: macOS (v2) Next Steps: Dispatching for Mac testing. Reviewed by Wails PR Reviewer Bot |
Summary
Fixes #5111
WKWebView does not automatically propagate the display's backing scale factor to JavaScript's
devicePixelRatiowhen content is loaded via the customwails://URL scheme. This causesdevicePixelRatioto return 1 on Retina displays, resulting in blurry canvas rendering for any app using<canvas>— terminal emulators, chart libraries, drawing tools, games, and code editors.Changes
_setOverrideDeviceScaleFactor:SPI call inWailsContext.mafter WKWebView initializationWailsWebView.hv2/test/5111/The SPI is stable since macOS 10.11 and is used by Electron, Playwright, and WebKit's own test infrastructure.
Test plan
window.devicePixelRatioreturns 2 (not 1)